﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Guoc.DAL.CastleIOC;
using Guoc.DAL.Domain;
using Guoc.DAL.Interface;
using Guoc.DAL.AOPFilter;
using Guoc.DAL.Common;
namespace Guoc.Web.Biz
{

    public class RoleBiz : BaseBusiness
    {
        public static readonly RoleBiz Instance = new RoleBiz();

        IRole roleService;
         
        public  RoleBiz() : this(null) { }

        public  RoleBiz(IRole irole)
        {
            //为null取右边值，不为null取左边值
            roleService = irole == null ? IocFactory<IRole>.GetService() : irole;
            //roleService =new Guoc.DAL.Service.RoleService();
        }

         public List<Role> GetRoleList(int page,int rows,out int count)
         {
            int total = 0;
            List<Role> list = roleService.GetList(page,rows, out total);
            count = total;
            return list;
         }

         public List<Role> QueryRoleList(string roleName, int page, int rows,out int count)
         {
             int total = 0;
             List<Role> list = roleService.QueryRoleList(roleName,page, rows, out total);
             count = total;
             return list;
         }

         public bool Create(Role role)
         {
             bool flag = false;
             try
             {
                 roleService.Create(role);
                 flag = true;
             }
             catch (Exception ex)
             {

                 Console.WriteLine(ex.Message);
             }
             return flag;
         }

         public bool Update(Role role)
         {
             return roleService.Update(role);
         }

         public bool Delete(Role role)
         {
             return roleService.Delete(role);
         }

         public bool Delete(string ids)
         {
             return roleService.Delete(ids);
         }

      
         public void MyAOP()
         {
             Console.WriteLine("测试事务");
         }
    }
}